package com.ccc.webhello;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.sql.SQLOutput;
import java.util.ArrayList;
import java.util.List;

@RestController
public class hello {
    @PostMapping("/dddd")
    public String data1(Book book){
        System.out.println(book);
        return "数据添加";
    }
    @GetMapping("/jj")
    public String hello() {
        return "ccccccc";
    }

    @PostMapping("/kk")
    public String test() {
        return "lxdsb";
    }

    @PostMapping("/ll")
    public wife jxlg() {
        wife wife = new wife(1, "list", 500);
        return wife;
    }

    @GetMapping("/mm")
    public List<wife> wifes() {
        wife wife = new wife(1, "wangwu", 4000);
        wife wife2 = new wife(2, "zhangsan", 3000);
        List<wife> list = new ArrayList<>();
        list.add(wife);
        list.add(wife2);
        return list;
    }

    @GetMapping("/person")
    public person person() {
        person person =
                new person(1, "kk", new wife(1, "lisi", 500));
        return person;
    }

    @PostMapping("/teacher")
    public teacher teacher() {
        teacher teacher = new teacher();
        teacher.setId(1);
        teacher.setName("lisi");

        List<wife> list = new ArrayList<>();
        list.add(new wife(1, "zhangsan", 500));
        list.add(new wife(2, "xiaoli", 400));
        teacher.setWifes(list);
        return teacher;

    }

    @PostMapping("/bb")
    public String revice(String name, int age) {
        System.out.println(name + "---->" + age);
        return "数据已收到";
    }


    @GetMapping("/data")
    public String data(student student) {
        System.out.println(student);
        return "数据收到";
    }
    @PostMapping("/findAll")
    public List<student>findAll(int id){
        System.out.println("接受的数据为："+id);
        List<student>students = new ArrayList<>();
        students.add(new student(1,"崔略","男",300));
        students.add(new student(1,"wuwu","男",300));
        students.add(new student(1,"zz","男",300));
        return students;
    }


}

